//package com.gy.handler;
//
//import cn.hutool.json.JSONUtil;
//import com.gy.entity.User;
//import com.gy.enumeration.FormEditMessageTypeEnum;
//import com.gy.event.FormEditEvent;
//import com.gy.message.FormEditRequestMessage;
//import com.gy.message.FormEditResponseMessage;
//import com.gy.service.UserService;
//import com.lmax.disruptor.WorkHandler;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.context.annotation.Lazy;
//import org.springframework.stereotype.Component;
//import org.springframework.web.socket.TextMessage;
//import org.springframework.web.socket.WebSocketSession;
//
//import javax.annotation.Resource;
//
//@Slf4j
//@Component
//public class FormEditEventWorkHandler implements WorkHandler<FormEditEvent> {
//
//    @Resource
//    @Lazy
//    private FormEditHandler formEditHandler;
//
//    @Resource
//    private UserService userService;
//
//    @Override
//    public void onEvent(FormEditEvent event) throws Exception {
//        FormEditRequestMessage pictureEditRequestMessage = event.getPictureEditRequestMessage();
//        WebSocketSession session = event.getSession();
//        User user = event.getUser();
//
//        Long formId = event.getFormId();
//
//        // 获取到消息类别
//        String type = pictureEditRequestMessage.getType();
//        FormEditMessageTypeEnum pictureEditMessageTypeEnum = FormEditMessageTypeEnum.valueOf(type);
//        // 调用对应的消息处理方法
//        switch (pictureEditMessageTypeEnum) {
//            case ENTER_EDIT:
//                formEditHandler.handleEnterEditMessage(pictureEditRequestMessage, session, user, formId);
//                break;
//            case EDIT_ACTION:
//                formEditHandler.handleEditActionMessage(pictureEditRequestMessage, session, user, formId);
//                break;
//            case EXIT_EDIT:
//                formEditHandler.handleExitEditMessage(pictureEditRequestMessage, session, user, formId);
//                break;
//            default:
//                FormEditResponseMessage pictureEditResponseMessage = new FormEditResponseMessage();
//                pictureEditResponseMessage.setType(FormEditMessageTypeEnum.ERROR.getValue());
//                pictureEditResponseMessage.setMessage("消息类型错误");
//                pictureEditResponseMessage.setUserId(user.getUserId());
//                session.sendMessage(new TextMessage(JSONUtil.toJsonStr(pictureEditResponseMessage)));
//        }
//    }
//}
